package com.pgytesting.secondhandcar.service.impl;

import com.pgytesting.secondhandcar.dao.WorkInfoDao;
import com.pgytesting.secondhandcar.model.WorkInfo;
import com.pgytesting.secondhandcar.service.WorkInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工作信息(WorkInfo)表服务实现类
 *
 * @author makejava
 * @since 2019-08-12 18:55:58
 */
@Service("workInfoService")
public class WorkInfoServiceImpl implements WorkInfoService {
    @Resource
    private WorkInfoDao workInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public WorkInfo queryById(String id) {
        return this.workInfoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<WorkInfo> queryAllByLimit(int offset, int limit) {
        return this.workInfoDao.queryAllByLimit(offset, limit);
    }
    
    /**
     * 条件查询多条数据
     *
     * @param workInfo 实例对象
     * @return 对象列表
     */
    @Override
    public List<WorkInfo> queryAll(WorkInfo workInfo) {
        return this.workInfoDao.queryAll(workInfo);
    }

    /**
     * 新增数据
     *
     * @param workInfo 实例对象
     * @return 实例对象
     */
    @Override
    public WorkInfo insert(WorkInfo workInfo) {
        this.workInfoDao.insert(workInfo);
        return workInfo;
    }

    /**
     * 修改数据
     *
     * @param workInfo 实例对象
     * @return 实例对象
     */
    @Override
    public WorkInfo update(WorkInfo workInfo) {
        this.workInfoDao.update(workInfo);
        return this.queryById(workInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.workInfoDao.deleteById(id) > 0;
    }
}